/*
 * Copyright 2020 edenrun.cn All right reserved. This software is the
 * confidential and proprietary information ofedenrun.cn ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with edenrun.cn.
 */

package com.zoom.pluto.openapi.config.swagger;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * 注入swagger的环境信息,确保生产环境Swagger接口不暴露出来
 *
 * @author zoom
 * @date 2020-06-05
 */
public class SwaggerCondition implements Condition {
    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        //从配置文件中获取属性
        String property = conditionContext.getEnvironment().getProperty("spring.profiles.active");
        if(property != null) {
            return ! property.contains("prd");
        } else {
            return false;
        }
    }

}
